{% extends _globals.page.layout %}

{% block style %}
    <link rel="stylesheet" href="/assets/libs/highlight/styles/{{ _globals.page.codeStyle }}.css">
{% endblock %}

{% block bottomScript %}
    <script src="/assets/libs/highlight/highlight.pack.js"></script>
    <script>hljs.initHighlightingOnLoad();</script>
{% endblock %}

{% block body %}
    <h1 class="article-title">{{ _globals.page.title }}</h1>

    <div class="well article-info">
        {% if _globals.page.tags %} {{ _globals.lang.tl('tags') }} : {% endif %}
        {% for tag in _globals.page.tags %}
            <span class="label label-primary">{{ tag }}</span>
        {% endfor %}

        {{ _globals.lang.tl('author') }} : <span class="label label-success">{{ _globals.page.author }}</span>

        {% if _globals.page.publishTime %}
            {{ _globals.lang.tl('publishTime') }} : <span class="label label-success">{{ _globals.page.publishTime|date('Y-m-d') }}</span>
        {% endif %}

        {% if _globals.page.readCount %}
            {{ _globals.lang.tl('readCount') }} : <span class="label label-success">{{ _globals.page.readCount }}</span>
        {% endif %}

        {# operate btn #}
        {% if _globals.user.isLogin() %}
            <div class="pull-right">
                <a class="btn btn-info btn-xs" href="{{ path_for('mder-page', {'action' : 'edit'}) }}?page={{ pagePath }}">
                    <span class="glyphicon glyphicon-pencil"></span>
                    {{ _globals.lang.tl('pageEdit') }}
                </a>
                <a class="btn btn-danger btn-xs" href="{{ path_for('mder-page',{'action':'del'}) }}" data-page="{{ pagePath }}">
                    <span class="glyphicon glyphicon-remove"></span>
                    {{ _globals.lang.tl('pageDel') }}
                </a>
            </div>
        {% endif %}
    </div>

    <div class="article-content">
        {{ content|raw }}
    </div>

    <nav class="article-nav">
        <ul class="pager">
            {% if _globals.page.prevPage is iterable %}
                <li>
                    <a href="{{ _globals.page.prevPage.url }}">
                        <span aria-hidden="true">&larr;</span> {{ _globals.page.prevPage.title }}
                    </a>
                </li>
            {% elseif _globals.page.prevPage != false %}
                <li class="disabled"><a href="#"><span aria-hidden="true">&larr;</span> {{ _globals.lang.tl('noPage') }}</a></li>
            {% endif %}

            {% if _globals.page.nextPage is iterable %}
                <li>
                    <a href="{{ _globals.page.nextPage.url }}">
                        {{ _globals.page.nextPage.title }} <span aria-hidden="true">&rarr;</span>
                    </a>
                </li>
            {% else %}
                <li class="disabled"><a href="#">{{ _globals.lang.tl('noPage') }} <span aria-hidden="true">&rarr;</span></a></li>
            {% endif %}
        </ul>
    </nav>

{% endblock %}

{% block sidebar %}
    {% include 'items/blog/sidebar.twig' %}
{% endblock %}